Is there any difference between var name = function() {} & function name() {} in Javascript?

Posted by Fletcher Moore on Stack Overflow See other posts from Stack Overflow or by Fletcher Moore
Published on 2010-05-28T20:17:53Z Indexed on 2010/05/28 20:22 UTC
Read the original article Hit count: 197

Filed under:
|

Suppose we are inside a function and not in the global namespace.

function someGlobalFunction() {
  var utilFunction1 = function() {
  }

  function utilFunction2 () {
  }

  utilFunction1();
  utilFunction2();

}

Are these synonymous? And do these functions completely cease to exist when someGlobalFunction returns? Should I prefer one or the other for readability or some other reason?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about best-practices